package tech.aistar.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import tech.aistar.interceptor.LoginInterceptor;

/**
 * 本类用来演示: springboot拓展springmvc功能
 *             比如 - 可以配置拦截器
 *
 * @author: success
 * @date: 2021/5/10 1:50 下午
 */
//@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginInterceptor)
//                .addPathPatterns("/**")//拦截所有的路径
//                .excludePathPatterns("/user/login")//排除哪些路径被拦截
//                .excludePathPatterns("/user/logincl");


        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//拦截所有的路径
                .excludePathPatterns("/user/index","/hello2");//排除哪些路径被拦截
    }
}
